package com.scott.ch010;

/**
 * @author 黄后林
 * @version 1.0
 * @note 定义一个学生类Student、具有年龄age和姓名studentName两个属性、并实现Comparable接口、提供比较规则。
 * @date 2022-05-02 10:21:11
 */
public class Student implements Comparable<Student> {

    private int age;
    private String studentName;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", studentName='" + studentName + '\'' +
                '}';
    }

    @Override
    public int compareTo(Student stu) {
        return this.getAge()-stu.getAge();
    }
}
